﻿{//文件上传页}
<extend name="Public/template/base.html"/>
<block name='head'></block>
<block name='header'>
<include file="./Public/template/nav.html" add="active"/>
</block>
<block name='content'>
<div class="title">
     <h2>设置打印信息<button class="btn btn-success" id="helpView">打印帮助</button></h2>
</div>
<div id="featured" class="container">
        <div class="row" style="display:none;" id="helpBlock"> 
    <div class="col-lg-8">
        <p class="text-info well">
        使用流程：<code>上传文件</code> -> <code>选择打印店</code> -> <code>设置打印份数、格式</code> -> <code>文件记录页查看状态</code> -><code> 取货</code>；<br/>
        不绑定手机不能设置打印参数，不能提前打印，只能上传后到店打印；<br/>
        暂时仅支持<code>pdf</code>、<code>doc(x)</code>、<code>wps</code>、<code>ppt(x)</code>格式的文件上传；<br/>
        如上传文件名出现<code>乱码</code>，请更换浏览器。电脑下Chrome效果最佳，手机建议使用UC浏览器；<br/>
        打印纸张统一为<code>A4</code>，有特殊需求可上传后到店打印；<br/>无论打印店队列多长，到店可直接取货。若打印店没有提前打印，你可以在店直接打印；<br/>
        对于提前打印的文件请于打印完成后<code>24小时</code>内取走；对于所有情况的打印请于<code>2天内</code>完成；<br/>
        当前提供价格仅供参考，所有打印店均可在<code>量大时减价</code>；</p>
    </div>
    </div>
    <br/>
    <form id="print" method="post" action="__URL__/uploadOne" onsubmit="return checkform();" enctype="multipart/form-data">
        <div class="row">
            <div class="text-center col-md-5">
                <div class="form-group">
                    <div class="upload-btn">
                        <div class="upload-area"><span class="glyphicon glyphicon-open"></span>点击上传文件<small>(不超过10MB)</small></div>
                        <input id="upload-file" type="file" name="file" accept="application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/pdf, application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" onchange="checkSuffix(this)">
                    </div>
                </div>
            </div>
        </div>
        

        <div class="row">
            <div class="col-sm-5">
                <ul id="upload-list" class="list-group"></ul>
            </div>
            
        </div>
        <br/>
    
    <div class="row">
        <div class="col-sm-6">
        <div class="form-group">
            <div class="row">
            <label for="PrinterChoose" class="col-sm-3 control-label">打印店</label>
                <div class="col-sm-7">
                <select class="form-control" name="pri_id" id="PrinterChoose" onchange="priceChange(this)" required>
                    <option value="">选择想去的打印店....</option>
                    <volist name="data" id="vo">
                      <option value="{$vo['id']}">{$vo.name}({$vo.address})</option>
                    </volist>
                </select>
                </div>
            </div>
            </div>
        <if condition="$lock eq 1">  
        <fieldset id="setting">
            <div class="form-group">
                <div class="row">
                <label for="copies" class="col-sm-3 control-label">打印份数</label>
                <div class="col-sm-7">
                    <input name="copies" type="number" id="copies" min="0" value="0" style="width:20%" /><strong>份</strong>&nbsp;<small style="font-size:13px;color:#AAAAAA">0表示到店后现场打印</small>
                </div>
                </div>
            </div>
            <div class="form-group">
                    <div style="display:none;" id="pptprint">
                        <div class="row">
                        <label for="default" class="col-sm-3 control-label">PPT格式</label>
                        <div class="col-sm-7">
                        <select id="default" class="form-control" name="ppt_layout" required>
                            <option value="">选择PPT打印格式....</option>
                            <volist name="ppt" id="vo" offset="1">
                                <option value="{$i}">{$vo}</option>
                            </volist>
                        </select>
                        </div>
                        </div>
                    </div>
            </div>
            <div class="form-group">
            <div class="row">
                <label for="moreSetting" class='col-sm-3 control-label'>更多设置</label>
                <div class="col-sm-7">
                <div class="checkbox" id="moreSetting">
                    <label for="printcolor">
                        <input name="color" id="printcolor" value="1" type="checkbox"><strong>彩印</strong>
                    </label>
                    <label for="double_side">
                        <input name="double_side" id='double_side' value="1" type="checkbox"><strong>双面打印</strong>
                    </label>
                </div>
                </div>
            </div>                
        </fieldset>
        <else/>
        <div>
            <a href="/User" style="text-decoration:none"><p>绑定手机后可进行高级设置提前打印</p></a>
        </div>
        </if>
        </div>
        <div class="col-sm-6 col-lg-4 well">
            <h4 class="text-info">该店价格信息</h4>
            <div id='price' class='help-block comments'>
                黑白单面：<span id='p_s' class='text-danger'></span><br/>
                黑白双面：<span id='p_d' class='text-danger'></span><br/>
                彩印单面：<span id='p_c_s' class='text-danger'></span><br/>
                彩印双面：<span id='p_c_d' class='text-danger'></span>
            </div>
        </div>
        
    </div>
    
    <div class="row">
        <div class="text-center col-lg-8">
            <button type="submit" class="btn btn-info" id="fileUploadButton" disabled="true">开始传送</button>
        </div>
    </div>
</form>

</div>
</block>

<block name='end'>
<script language="javascript" type="text/javascript">
function checkSuffix(n) {
    var pos = n.value.lastIndexOf('.');
    var suffix = n.value.substring(pos + 1);
    var doc_suffix = ['doc', 'docx', 'wps'];
    var pdf_suffix = ['pdf'];
    var other_suffix = ['ppt', 'pptx'];
    if (doc_suffix.indexOf(suffix) >= 0) {
        alert('打印小常识：将文档转成PDF格式，打印出来的格式基本不会发生变化！（任性就随意了(^▽^)）')
        $('#default').removeAttr('required');
        $('#setting').show();
        $('#pptprint').hide();
        $('#copies').attr('disabled', false);
        $('#double_side').attr('disabled', false);
        $("#fileUploadButton").attr('disabled', false);
        var fname = n.value.substring(n.value.lastIndexOf('\\')+1);
        $("#upload-list").html('<li class="list-group-item">当前文件：'+ fname +'</li>'+'<li class="list-group-item">支持的格式，但更推荐pdf。');
    } else if (other_suffix.indexOf(suffix)>=0) {
        $('#pptprint').show();
        $('#setting').show();
        $('#copies').attr('disabled', false);
        $('#double_side').attr('disabled', false);
        $("#fileUploadButton").attr('disabled', false);
        var fname = n.value.substring(n.value.lastIndexOf('\\')+1);
        $("#upload-list").html('<li class="list-group-item">当前文件：'+fname +'</li>');
    } else if(pdf_suffix.indexOf(suffix) >= 0){
        $('#default').removeAttr('required');
        $('#setting').show();
        $('#pptprint').hide();
        $('#copies').attr('disabled', false);
        $('#double_side').attr('disabled', false);
        $("#fileUploadButton").attr('disabled', false);
        var fname = n.value.substring(n.value.lastIndexOf('\\')+1);
        $("#upload-list").html('<li class="list-group-item">当前文件：'+fname +'</li>');
    } else {
        $("#upload-list").html('<li class="list-group-item">不支持'+ suffix + '格式文件。</li>');
        $("#fileUploadButton").attr('disabled',true);
    }
}

function priceChange(n){
    var pid = n.value;
    var URL = "/Printers/getPrice";
    $.post(URL, {
            pid : pid
        }, function(data) {
            if (data.status) {
                $('#p_c_s').html(data.info.p_c_s+'元/张');
                $('#p_c_d').html(data.info.p_c_d+'元/张');
                $('#p_s').html(data.info.p_s+'元/张');
                $('#p_d').html(data.info.p_d+'元/张');
            } else {
                $('#p_c_s').html("未设置");
                $('#p_c_d').html("未设置");
                $('#p_s').html("未设置");
                $('#p_d').html("未设置");
            }
        });
}

function checkform(){
    $('#fileUploadButton').attr('disabled',true);
    $('#fileUploadButton').html('正在传送中');
    return true;
}

$("#helpView").click(function(){
    $('#helpView').toggleClass('btn-warning')
    $('#helpBlock').toggle(100);
});
</script>
</block>
